//
//  CJSHeadView.m
//  GoTraveling
//
//  Created by 陈金山 on 15/12/24.
//  Copyright © 2015年 开发华佗. All rights reserved.
//

#import "CJSHeadView.h"

@interface CJSHeadView ()

@property (nonatomic, retain) UIImageView *imageView;

@property (nonatomic, retain) UILabel *title;

@end

@implementation CJSHeadView


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }
    return self;
}

- (void)createSubViews {
    
    self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10 * ADAPT_WIDTH, 0, 8 * ADAPT_WIDTH, 25 * ADAPT_HEIGHT)];
    self.imageView.center = CGPointMake(self.imageView.center.x, self.center.y + 5 * ADAPT_WIDTH);
    self.imageView.layer.cornerRadius = 4;
    self.imageView.layer.masksToBounds = YES;
    [self addSubview:self.imageView];
    
    self.title = [[UILabel alloc] initWithFrame:CGRectMake(self.imageView.frame.origin.x + self.imageView.frame.size.width + 10 * ADAPT_WIDTH, self.imageView.frame.origin.y, SCREEN_WIDTH - 30 * ADAPT_WIDTH, self.imageView.frame.size.height)];
    self.title.font = [UIFont systemFontOfSize:20 weight:0.1];
    self.title.textColor = [UIColor colorWithRed:0.29 green:0.29 blue:0.3 alpha:1];
    [self addSubview:self.title];
}

- (void)showSectionTitle:(NSInteger)section {
    
    self.imageView.image = [UIImage imageNamed:@"login_btn"];
    NSString *string;
    if (section == 0) {
        
        string = @"每日故事精选";
    }
    else {
        
        string = @"精彩游记和专题";
    }
    self.title.text = string;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
